| Conditions | 6 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | class Validate { |
||
| 17 | sourceConfiguration (input, callback) { |
||
| 18 | let error = null |
||
| 19 | |||
| 20 | if (!input.source.url) { |
||
| 21 | if (!error) { |
||
| 22 | error = new Error('URL for MQTT broker has not been set.') |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 26 | if (!this.url(input.source.url)) { |
||
| 27 | if (!error) { |
||
| 28 | error = new Error('Your defined URL is invalid. It should start with mqtt://') |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | let port = Number.parseInt(input.source.port) |
||
| 33 | if (Number.isNaN(port)) { |
||
| 34 | input.source.port = 1883 |
||
| 35 | } else { |
||
| 36 | input.source.port = port |
||
| 37 | } |
||
| 38 | |||
| 39 | callback(input, error) |
||
| 40 | } |
||
| 41 | |||
| 74 |